package com.kikt.eventbustest;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import butterknife.Bind;
import butterknife.ButterKnife;
import butterknife.OnClick;
import de.greenrobot.event.EventBus;
import de.greenrobot.event.Subscribe;
import de.greenrobot.event.ThreadMode;

public class SecondActivity extends AppCompatActivity {

    @Bind(R.id.bt1)
    Button mBt1;
    @Bind(R.id.tv)
    TextView mTv;
    private User user;


    @OnClick(R.id.bt1)
    public void onClick(View view) {
        user.name = "2222";
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        ButterKnife.bind(this);
        EventBus.getDefault().register(this);
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        EventBus.getDefault().unregister(this);
    }

    @Subscribe(sticky = true)
    public void onSticky(PostEvent event) {
        this.user = event.user;
    }

    @Subscribe(threadMode = ThreadMode.PostThread, sticky = true)
    public void onEvent() {

    }
}
